function checkform() {
	if (hj$('username') && hj$('username').value == "") {
		alert("请输入您的名字.");
		return false;
	}
	if (hj$('content') && hj$('content').value == "")	{
		alert("请输入内容.");
		return false;
	}
	if (hj$('clientcode') && hj$('clientcode').value == "")	{
		alert("请输入验证码.");
		return false;
	}
	if (((postminchars != 0 && hj$('content').value.length < postminchars) || (postmaxchars != 0 && hj$('content').value.length > postmaxchars))) {
		alert("您的评论内容长度不符合要求。\n\n当前长度: "+hj$('content').value.length+" 字节\n系统限制: "+postminchars+" 到 "+postmaxchars+" 字节");
		return false;
	}
	hj$('submit').disabled = true;
	return true;
}

function ctlent(event) {
	if((event.ctrlKey && event.keyCode == 13) || (event.altKey && event.keyCode == 83)) {
		hj$("submit").click();
	}
}

function addreply(obj,strAuthor,cmid){
//	var text = $(obj).innerHTML;
//	text = text.replace(/alt\=(\"|)([^\"\s]*)(\"|)/g,">$2<");
//	text = text.replace(/\<[^\<\>]+\>/g,"");
//	text = text.replace(/ +/g," ");
//	text = text.replace(/\n+/g,"\n");
//	text = text.replace(/^\n*/gm,"");
//	text = text.replace(/^\s*/gm,"");
//	text = text.replace(/\n*$/gm,"");
//	text = text.replace(/\s*$/gm,"");
//	text = text.replace(/&lt;/g,"<");
//	text = text.replace(/&gt;/g,">");
//	text = text.replace(/&nbsp;&nbsp;/g,"  ");
//	text = text.replace(/&amp;/g,"&");(^0^)｡oＯ
	hj$("content").value += '[:D=>'+strAuthor+'#'+cmid+']';
	hj$("content").focus();
}

function addquote(obj,strAuthor){
	var text = hj$(obj).innerHTML;
	text = text.replace(/alt\=(\"|)([^\"\s]*)(\"|)/g,"> $2 <");
	text = text.replace(/\<[^\<\>]+\>/g,"");
	text = text.replace(/ +/g," ");
	text = text.replace(/\n+/g,"\n");
	text = text.replace(/^\n*/gm,"");
	text = text.replace(/^\s*/gm,"");
	text = text.replace(/\n*$/gm,"");
	text = text.replace(/\s*$/gm,"");
	text = text.replace(/&lt;/g,"<");
	text = text.replace(/&gt;/g,">");
	text = text.replace(/&nbsp;&nbsp;/g,"  ");
	text = text.replace(/&amp;/g,"&");
	hj$("content").value += "[quote="+strAuthor+"]"+text+"[/quote]";
	hj$("content").focus();
}

function addsmiles(facename){
	hj$("content").value += "[face="+facename+"]";
	hj$("content").focus();
}

function showajaxdiv(action, url, width) {
	var x = new Ajax('statusid', 'XML');
	x.get(url, function(s) {
		if(hj$("ajax-div-"+action)) {
			var oDiv = hj$("ajax-div-"+action);
		} else {
			var oDiv = document.createElement("DIV");
			oDiv.id = "ajax-div-"+action;
			oDiv.className = "ajaxdiv";
			document.body.appendChild(oDiv);
		}
		var oDivStyle = oDiv.style;
		oDivStyle.display = "";
		oDivStyle.width = width + "px";

		var userAgent = navigator.userAgent.toLowerCase();
		var is_opera = (userAgent.indexOf('opera') != -1);
		var clientHeight = scrollTop = 0;
		if(is_opera) {
			clientHeight = document.body.clientHeight /2;
			scrollTop = document.body.scrollTop;
		} else {
			clientHeight = document.documentElement.clientHeight /2;
			scrollTop = document.documentElement.scrollTop;
		}
		oDiv.innerHTML = s.lastChild.firstChild.nodeValue;
		oDivStyle.left = (document.documentElement.clientWidth /2 +document.documentElement.scrollLeft - width/2)+"px";
		oDivStyle.top = (clientHeight +　scrollTop - oDiv.clientHeight/2)+"px";
	});
}

function setCopy(content){
	if(navigator.userAgent.toLowerCase().indexOf('ie') > -1) {
		clipboardData.setData('Text',content);
		alert ("该地址已经复制到剪切板");
	} else {
		prompt("请复制网站地址:",content);
	}
}

function tagshow(tag) {
	var width = 500;
	var x = new Ajax('statusid', 'XML');
	x.get(blogurl + 'getxml.php?action=tag&item=' + encodeURIComponent(tag), function(s) {
		if(hj$("ajax-div-tagshow")) {
			var oDiv = hj$("ajax-div-tagshow");
		} else {
			var oDiv = document.createElement("DIV");
			oDiv.id = "ajax-div-tagshow";
			oDiv.className = "ajaxdiv";
			document.body.appendChild(oDiv);
		}
		var oDivStyle = oDiv.style;
		oDivStyle.display = "";
		oDivStyle.width = width + "px";

		var userAgent = navigator.userAgent.toLowerCase();
		var is_opera = (userAgent.indexOf('opera') != -1);
		var clientHeight = scrollTop = 0;
		if(is_opera) {
			clientHeight = document.body.clientHeight /2;
			scrollTop = document.body.scrollTop;
		} else {
			clientHeight = document.documentElement.clientHeight /2;
			scrollTop = document.documentElement.scrollTop;
		}
		oDiv.innerHTML = s.lastChild.firstChild.nodeValue;
		oDivStyle.left = (document.documentElement.clientWidth /2 +document.documentElement.scrollLeft - width/2)+"px";
		oDivStyle.top = (clientHeight +　scrollTop - oDiv.clientHeight/2)+"px";
	});
}

function updatesmiley( url ) {
	hj$('smiley').innerHTML = '<br /><img style="cursor:pointer;" onclick="addsmiles(\'surprise\')" src="' + url + 'images/smiles/surprise.gif" /><img alt="glade" style="cursor:pointer;" onclick="addsmiles(\'glade\')" src="' + url + 'images/smiles/glade.gif" /><img alt="love" style="cursor:pointer;" onclick="addsmiles(\'love\')" src="' + url + 'images/smiles/love.gif" /><img alt="cry" style="cursor:pointer;" onclick="addsmiles(\'cry\')" src="' + url + 'images/smiles/cry.gif" /><img alt="sing" style="cursor:pointer;" onclick="addsmiles(\'sing\')" src="' + url + 'images/smiles/sing.gif" /><img alt="fight" style="cursor:pointer;" onclick="addsmiles(\'fight\')" src="' + url + 'images/smiles/fight.gif" /><img alt="bitter" style="cursor:pointer;" onclick="addsmiles(\'bitter\')" src="' + url + 'images/smiles/bitter.gif" /><img alt="dream" style="cursor:pointer;" onclick="addsmiles(\'dream\')" src="' + url + 'images/smiles/dream.gif" /><img alt="approve" style="cursor:pointer;" onclick="addsmiles(\'approve\')" src="' + url + 'images/smiles/approve.gif" /><img alt="dissatisfy" style="cursor:pointer;" onclick="addsmiles(\'dissatisfy\')" src="' + url + 'images/smiles/dissatisfy.gif" /><img alt="question" style="cursor:pointer;" onclick="addsmiles(\'question\')" src="' + url + 'images/smiles/question.gif" /><img alt="plaint" style="cursor:pointer;" onclick="addsmiles(\'plaint\')" src="' + url + 'images/smiles/plaint.gif" /><img alt="slaver" style="cursor:pointer;" onclick="addsmiles(\'slaver\')" src="' + url + 'images/smiles/slaver.gif" /><img alt="incisor" style="cursor:pointer;" onclick="addsmiles(\'incisor\')" src="' + url + 'images/smiles/incisor.gif" /><img alt="whistle" style="cursor:pointer;" onclick="addsmiles(\'whistle\')" src="' + url + 'images/smiles/whistle.gif" /><img alt="pain" style="cursor:pointer;" onclick="addsmiles(\'pain\')" src="' + url + 'images/smiles/pain.gif" /><img alt="feed" style="cursor:pointer;" onclick="addsmiles(\'feed\')" src="' + url + 'images/smiles/feed.gif" /><img alt="esotropia" style="cursor:pointer;" onclick="addsmiles(\'esotropia\')" src="' + url + 'images/smiles/esotropia.gif" /><img alt="faint" style="cursor:pointer;" onclick="addsmiles(\'faint\')" src="' + url + 'images/smiles/faint.gif" /><img alt="innocent" style="cursor:pointer;" onclick="addsmiles(\'innocent\')" src="' + url + 'images/smiles/innocent.gif" /><br /><img alt="fuck" style="cursor:pointer;" onclick="addsmiles(\'fuck\')" src="' + url + 'images/smiles/fuck.gif" /><img alt="young" style="cursor:pointer;" onclick="addsmiles(\'young\')" src="' + url + 'images/smiles/young.gif" /><img alt="football" style="cursor:pointer;" onclick="addsmiles(\'football\')" src="' + url + 'images/smiles/football.gif" /><img alt="dead" style="cursor:pointer;" onclick="addsmiles(\'dead\')" src="' + url + 'images/smiles/dead.gif" /><img alt="terror" style="cursor:pointer;" onclick="addsmiles(\'terror\')" src="' + url + 'images/smiles/terror.gif" /><img alt="none" style="cursor:pointer;" onclick="addsmiles(\'none\')" src="' + url + 'images/smiles/none.gif" /><img alt="smile" style="cursor:pointer;" onclick="addsmiles(\'smile\')" src="' + url + 'images/smiles/smile.gif" /><img alt="awkard" style="cursor:pointer;" onclick="addsmiles(\'awkard\')" src="' + url + 'images/smiles/awkard.gif" /><img alt="frisk" style="cursor:pointer;" onclick="addsmiles(\'frisk\')" src="' + url + 'images/smiles/frisk.gif" /><img alt="fire" style="cursor:pointer;" onclick="addsmiles(\'fire\')" src="' + url + 'images/smiles/fire.gif" /><img alt="sick" style="cursor:pointer;" onclick="addsmiles(\'sick\')" src="' + url + 'images/smiles/sick.gif" /><img alt="sinister" style="cursor:pointer;" onclick="addsmiles(\'sinister\')" src="' + url + 'images/smiles/sinister.gif" /><img alt="sleep" style="cursor:pointer;" onclick="addsmiles(\'sleep\')" src="' + url + 'images/smiles/sleep.gif" /><img alt="shutup" style="cursor:pointer;" onclick="addsmiles(\'shutup\')" src="' + url + 'images/smiles/shutup.gif" /><img alt="tongue" style="cursor:pointer;" onclick="addsmiles(\'tongue\')" src="' + url
 + 'images/smiles/tongue.gif" /><img alt="cool" style="cursor:pointer;" onclick="addsmiles(\'cool\')" src="' + url + 'images/smiles/cool.gif" /><img alt="disch" style="cursor:pointer;" onclick="addsmiles(\'disch\')" src="' + url + 'images/smiles/disch.gif" /><img alt="deride" style="cursor:pointer;" onclick="addsmiles(\'deride\')" src="' + url + 'images/smiles/deride.gif" /><img alt="angry" style="cursor:pointer;" onclick="addsmiles(\'angry\')" src="' + url + 'images/smiles/angry.gif" /><img alt="shy" style="cursor:pointer;" onclick="addsmiles(\'shy\')" src="' + url + 'images/smiles/shy.gif" />';}
